﻿using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;

namespace Hiver.WebApi.Installers
{
    /// <summary>
    /// Business Cache Data以及Util类库服务注册
    /// </summary>
    public class ServiceInstaller : IWindsorInstaller
    {
        /// <summary>
        /// 安装服务
        /// </summary>
        /// <param name="container"></param>
        /// <param name="store"></param>
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            // 注册格式
            container.Register(Classes.FromAssemblyNamed("Hiver.Data")
                            .Where(type => type.Name.EndsWith("Repository")).WithServiceDefaultInterfaces().LifestyleTransient());
            container.Register(Classes.FromAssemblyNamed("Hiver.Business")
                            .Where(type => type.Name.EndsWith("Service")).WithServiceDefaultInterfaces().LifestyleTransient());
        }
    }
}